import Ember from 'ember';
import config from 'game-front/config/environment';
import RSVP from 'rsvp';

export default Ember.Route.extend({
  share:Ember.inject.service(),
  model() {
    const userInfo = this.modelFor("application");
    console.log(userInfo);
    return RSVP.hash({
      userInfo: userInfo,
      isFirstTime: Ember.$.getJSON(config.apiBase + "members/played", {userId: userInfo.userId, gameZoneProductId:"2"})
    });
  },
  afterModel: function() {
    const userId = sessionStorage.getItem("userId");
    const shareLink = {
      title: '90秒夺宝-PM大逃亡', // 分享标题
      desc: '这是一款神奇的游戏，只要存活时间长就可轻松赢取大奖',
      link: window.location.origin + config.baseURL + 'game-twoshare?public=true&key=' + userId, // 分享链接
      imgUrl: 'http://game.inkanke.com/yydb/assets/images/ICON2.png', // 分享图标
      success: function () {
        share.reward(userId);
        // 生成推荐二维码
        share.createQR(userId);
      },
      cancel: function () {
        // 用户取消分享后执行的回调函数
      }
    };
    const share = this.get("share");
    share.config(shareLink);
  },
  actions:{
    home () {
      if (parseInt($(".user-prise").text()) < 2 ){
        $(".shade").css({"display":"block"});
        $(".div-shade").css({"display":"block"});
      }else {
        $(".shade").css({"display":"block"});
        $(".div-shade-teo").css({"display":"block"});
      }
    },nohover() {
      $(".shade").css({"display":"none"});
      $(".div-shade").css({"display":"none"});
    }
  }
});
